function assignedTTChange() {
    var combo = document.getElementById('assignedTTCombo');
    var type = combo.options[combo.selectedIndex].value;
    location.href = "showTickets.php?status=" + type + "&MAView=true";
}

function myTTChange() {
    var combo = document.getElementById('myTTCombo');
    var type = combo.options[combo.selectedIndex].value;
    location.href = "showTickets.php?status=" + type;
}

function disable() {
    document.getElementById('state').disabled = true;
    document.getElementById('storeAbbrev').disabled = true;
}

function ttBoxChange(ttid) {
    var strURL="JavaScript/phpHandlers/showTickets_ticketInfo.php?ttid=" + ttid;
    var req = getXMLHTTP();
    if (req) {
        req.onreadystatechange = function() {
            if (req.readyState == 4) {
                // only if "OK"
                if (req.status == 200) {
                    document.getElementById('ticketInfo').innerHTML=req.responseText;
                } else {
                    alert("There was a problem while using XMLHTTP in showTickets_ajax.ttBoxChange:\n" + req.statusText);
                }
            }
        }
        req.open("GET", strURL, true);
        req.send(null);
        fetchStatusHistory(ttid);
    }
}

function fetchStatusHistory(ttid) {
    var strURL="JavaScript/phpHandlers/showTickets_ticketHistory.php?ttid=" + ttid;
    var req = getXMLHTTP();
    if (req) {
        req.onreadystatechange = function() {
            if (req.readyState == 4) {
                // only if "OK"
                if (req.status == 200) {
                    document.getElementById('ticketHistory').innerHTML=req.responseText;
                } else {
                    alert("There was a problem while using XMLHTTP in showTickets_ajax.fetchStatusHistory:\n" + req.statusText);
                }
            }
        }
        req.open("GET", strURL, true);
        req.send(null);
        allowStatusChange(ttid);
    }
}

function allowStatusChange(ttid) {
    var strURL="JavaScript/phpHandlers/showTickets_changeStatus.php?ttid=" + ttid;
    var req = getXMLHTTP();
    if (req) {
        req.onreadystatechange = function() {
            if (req.readyState == 4) {
                // only if "OK"
                if (req.status == 200) {
                    document.getElementById('changeStatus').innerHTML=req.responseText;
                } else {
                    alert("There was a problem while using XMLHTTP in showTickets_ajax.fetchStatusHistory:\n" + req.statusText);
                }
            }
        }
        req.open("GET", strURL, true);
        req.send(null);
    }
}

function getXMLHTTP() {
    var xmlhttp=false;
    try{
        xmlhttp=new XMLHttpRequest();
    }
    catch(e)	{
        try{
            xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch(e){
            try{
                xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
            }
            catch(e1){
                xmlhttp=false;
            }
        }
    }
    return xmlhttp;
}